package org.dolphin.entity.district;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.dolphin.base.constant.DatabaseAttribute;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.util.ObjectUtils;

@Entity
@Table(name = "XS_COUNTRY", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME"}, name = "UQ_XS_COUNTRY_NAME")})
public class Country implements Serializable {
  private static final long serialVersionUID = -7532369953778884579L;
  private String id;
  private String name;

  @Override
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    } else if (obj instanceof Country) {
      Country oth = (Country) obj;
      return ObjectUtils.nullSafeEquals(getId(), oth.getId());
    }
    return false;
  }

  @Id
  @GeneratedValue(generator = "uuid2")
  @GenericGenerator(name = "uuid2", strategy = "org.dolphin.base.id.generator.CustomUUIDGenerator")
  @Column(name = "ID", nullable = false, length = DatabaseAttribute.ID_LENGTH)
  public String getId() {
    return id;
  }

  @Column(name = "NAME", nullable = false, length = 200)
  public String getName() {
    return name;
  }

  @Override
  public int hashCode() {
    return ObjectUtils.nullSafeHashCode(getId());
  }

  public void setId(String id) {
    this.id = id;
  }

  public void setName(String name) {
    this.name = name;
  }
}
